package com.xbongbong.pro.enums;

import lombok.Getter;

import java.util.Objects;


/***
 * 销客与精线索字段对应关系
 *
 * @author hongxiao
 * @date 2021-12-25 20:33
 */
@Getter
public enum FineClueMatchSearchEnum {

    /**
     * 销客工商查询字段：29个
     * 精线索工商查询字段：25个
     * 对应字段为20个，无法对应9个
     */
    // 企业名称
    ENTERPRISE_NAME(BusinessFineClueEnum.ENTERPRISE_NAME, BusinessSearchEnum.ENTERPRISE_NAME),
    // 历史名称
    HISTORY_NAME(BusinessFineClueEnum.HISTORY_NAME, BusinessSearchEnum.HISTORY_NAME),
    // 法人代表
    LEGAL_REPRESENTATIVE(BusinessFineClueEnum.LEGAL_REPRESENTATIVE, BusinessSearchEnum.LEGAL_PERSON),
    // 成立日期
    DATE_OF_ESTABLISHMENT(BusinessFineClueEnum.DATE_OF_ESTABLISHMENT, BusinessSearchEnum.ESTABLISH_DATE),
    // 注册号
    REGISTRATION_NUMBER(BusinessFineClueEnum.REGISTRATION_NUMBER, BusinessSearchEnum.REGISTER_NUMBER),
    // 统一社会信用代码
    UNIFY_SOCIAL_CREDIT_CODE(BusinessFineClueEnum.UNIFY_SOCIAL_CREDIT_CODE, BusinessSearchEnum.UNIFORM_CREDIT_CODE),
    // 企业类型
    ENTERPRISE_TYPE(BusinessFineClueEnum.ENTERPRISE_TYPE, BusinessSearchEnum.ENTERPRISE_TYPR),
    // 注册资金
    REGISTERED_CAPITAL(BusinessFineClueEnum.REGISTERED_CAPITAL, BusinessSearchEnum.REGISTER_FUNDS),
    // 省份代码
    PROVINCE_CITY(BusinessFineClueEnum.PROVINCE_CITY, BusinessSearchEnum.PROVINCE_CODE),
    // 登记机关
    REGISTRATION_AUTHORITY(BusinessFineClueEnum.REGISTRATION_AUTHORITY, BusinessSearchEnum.REGISTER_AUTHORITY),
    // 注销日期
    CANCELLATION_DATE(BusinessFineClueEnum.CANCELLATION_DATE, BusinessSearchEnum.LOGOUT_DATE),
    // 核准日期
    APPROVAL_DATE(BusinessFineClueEnum.APPROVAL_DATE, BusinessSearchEnum.APPROVAL_DATE),
    // 企业状态
    OPERATING_STATE(BusinessFineClueEnum.OPERATING_STATE, BusinessSearchEnum.ENTERPRISE_STATUS),
    //精线索字段operatingPeriod:"2020-10-10-2020-20-20"--拆分为OPERATING_PERIOD_START，OPERATING_PERIOD_END
    // 营业期限自
    OPERATING_PERIOD_START(BusinessFineClueEnum.OPERATING_PERIOD_START, BusinessSearchEnum.OPERATE_PERIOD_FROM),
    // 营业期限至
    OPERATING_PERIOD_END(BusinessFineClueEnum.OPERATING_PERIOD_END, BusinessSearchEnum.OPERATE_PERIOD_TO),
    // 注册地址
    REGISTERED_ADDRESS(BusinessFineClueEnum.REGISTERED_ADDRESS, BusinessSearchEnum.REGISTER_ADDRESS),
    // 经营范围
    SCOPE_OF_BUSINESS(BusinessFineClueEnum.SCOPE_OF_BUSINESS, BusinessSearchEnum.MANAGE_SCOPE),
    // 股东
    SHAREHOLDER(BusinessFineClueEnum.SHAREHOLDER, BusinessSearchEnum.SHAREHOLDER),
    // 股东名
    SHAREHOLDER_NAME(BusinessFineClueEnum.SHAREHOLDER_NAME, BusinessSearchEnum.SHAREHOLDER_NAME),
    // 股东类型
    SHAREHOLDER_TYPE(BusinessFineClueEnum.SHAREHOLDER_TYPE, BusinessSearchEnum.SHAREHOLDER_TYPE),
    /**
     * 销客无法对应到精线索字段
     * 1. LEGAL_PERSON_TYPE（法人名称类型）
     * 2. MAIN_MEMBER（主要成员）
     * 3. CLEARINGINFO（清算信息）
     * 4. NAME（姓名）
     * 5. POSITION（职务）
     * 6. CLEARING_GROUP_MEMBER_NAME（清算组成员名称）
     * 7. CLEARING_GROUP_MEMBER_TYPE（清算组成员类型）
     * 8. MOBILE（联系电话）
     * 9. EMAIL（邮箱）
     */
    ;

    /**
     * 精线索字段
     */
    private BusinessFineClueEnum fineClueEnum;

    /**
     * 字段变量名
     */
    private BusinessSearchEnum businessSearchEnum;

    FineClueMatchSearchEnum(BusinessFineClueEnum fineClueEnum, BusinessSearchEnum businessSearchEnum) {
        this.fineClueEnum = fineClueEnum;
        this.businessSearchEnum = businessSearchEnum;
    }


    public static BusinessFineClueEnum getByCode(Integer code) {
        for (FineClueMatchSearchEnum matchEnum : values()) {
            if (Objects.equals(code,matchEnum.getBusinessSearchEnum().getCode())) {
                return matchEnum.getFineClueEnum();
            }
        }
        return null;
    }
}
